<template>
  <div>
    <a-form
      :label-col="{ md: { span: 7 }, sm: { span: 4 }, xs: { span: 24 } }"
      :wrapper-col="{ md: { span: 17 }, sm: { span: 20 }, xs: { span: 24 } }"
    >
      <a-row :gutter="24">
        <a-col :md="24" :sm="24" :xs="24">
          <vxe-table
            :column-config="{ resizable: true }"
            :data="tableData"
            @radio-change="selectChangeEvent"
          >
            <vxe-column type="radio" width="80" />
            <vxe-column field="name" title="货品信息" />
            <vxe-column field="num" title="数量" />
            <vxe-column field="store_name" title="门店" />
            <vxe-column field="pay_amount" title="金额(元)" />
            <vxe-column field="main_salesman_name" title="主销导购" />
            <vxe-column field="sales_time" title="销售时间" />
          </vxe-table>
        </a-col>
      </a-row>
    </a-form>
  </div>
</template>

<script setup>
  import { ref, reactive, onMounted, watch } from 'vue';
  import { Modal, message, Form } from 'ant-design-vue';
  import dayjs from 'dayjs';
  import { uploadUrl } from '@/config/setting';
  import { emailReg, phoneReg, identityReg } from 'ele-admin-pro';
  import { PlusOutlined, LoadingOutlined } from '@ant-design/icons-vue';
  import { get_new_exchange_buy } from '@/api/order/order/jewelry_order';

  // 表格列配置
  const useForm = Form.useForm;

  const props = defineProps({
    // 弹窗是否打开
    visible: Boolean,
    member_id: [Number, String]
  });

  const emit = defineEmits(['getBarCode3', 'update:visible']);

  const loading = ref(false);
  const tableData = ref([]);

  const form = reactive({
    member_id: props.member_id,
    order_item: []
  });
  
  watch(
  	() => [
  		props.member_id
  	],
  	(newValue, oldValue) => {
			getList();
  	}
  );
  const getList = ()=>{
	  if(props.member_id){
	  	get_new_exchange_buy({
	  		member_id: props.member_id,
	  		bar_code: ''
	  	})
	  		.then((res) => {
	  			tableData.value = res.data;
	  		})
	  		.catch((e) => {
	  			message.error(e);
	  		});
	  }
  }
	getList();

  const selectChangeEvent = ({ $table }) => {
    const records = $table.getRadioRecord();
    emit('getBarCode3', records);
  };
</script>
<style scoped></style>
